package com.example.springboot.controller;

import com.example.springboot.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HomeController {
    @Autowired
    private Student student;
    @RequestMapping("/home")
    public String homePage(){
        // 返回 resources/templates/ 下的 home.html
        return "home";
    }
    @RequestMapping("/home-json")
    @ResponseBody
    public Student homePageJson(){
        System.out.println("---name"+student.getName());
        student.setName("xiaoming");
        student.setNum(1);
        return student;
    }
    @RequestMapping(value = "show", method = RequestMethod.GET)
    public String show(Model model){
        model.addAttribute("uid","123456789");
        model.addAttribute("name","Jerry");
        return "show";
    }
}